package com.mali.malibackendlog;

import com.alipay.sofa.rpc.config.ConsumerConfig;
import com.mali.backendcommon.config.WebMvcConfiguration;
import com.mali.backendcommon.rpc.ProductService;
import com.mali.backendcommon.rpc.UserService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;

@SpringBootApplication
@ComponentScan("com.mali")
@Import(WebMvcConfiguration.class)
@MapperScan(basePackages = "com.mali.malibackendlog.mapper")
public class MaliBackendLogApplication {

    public static void main(String[] args) {
        SpringApplication.run(MaliBackendLogApplication.class, args);
    }

    @Bean
    public ProductService productService() {
        ConsumerConfig<ProductService> consumerConfig = new ConsumerConfig<ProductService>()
                .setInterfaceId(ProductService.class.getName())
                .setProtocol("bolt")
                .setDirectUrl("bolt://127.0.0.1:12201") // 服务 B 的地址
                .setUniqueId("1.0");                    // 设置版本号，与服务 B 一致
        return consumerConfig.refer();
    }
}
